﻿var status = -1;
var icon = "#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#";
function start() {
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == 1) {
		status++;
	} else {
		if (status >= 0) {
			cm.dispose();
			return;
		}
		status--;
	}
	if (status == 0) {
		cm.sendYesNo("点击是以后将解锁装备栏下的所有锁定装备，是否需要解锁？");
	} else if (status == 1) {
		unlock();
		cm.sendOk("锁定装备解锁成功。");
		cm.dispose();
	} 
}

function unlock() {
	var itemList = cm.getInventory(1).list().iterator();
	while(itemList.hasNext()) {
		var item = itemList.next();
		if (item.getFlag() & 0x01 == 0x01) {
			item.setFlag(item.getFlag() & ~ 0x01);
			item.setExpiration(-1);
		}
		cm.getPlayer().forceUpdateItem(item);
	}
	cm.dispose();
}
